home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Logiciels PC 18
/
LOGICIELSPC_18.ISO
/
Accuses
/
MAJ
/
Rtf2Html
/
Source C
/
RTFPARSE
/
RTFPARSE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1999-06-27
|
38KB
|
1,281 lines
/*
* %%File: rtfparse.c
*
* Copyright (c) 1995-1999 Bertrand LE QUELLEC
* Copyright (c) 1989-1995 Microsoft Corporation.
*
*
* http://perso.wanadoo.fr/blq
* blq@wanadoo.fr
*/
#include <stdio.h>
#include <stddef.h>
#include "html.h"
#include "rtftype.h"
#include "rtfdecl.h"
#include "rtfreadr.h"
#include "mparse.h"
#include "rtfhtml.h"
#define SOURCE_ACTN 1
#include "rtfparse.h"
/*
* RTF parser tables
* Property descriptions
*/
PROP rgprop [ipropMax] = {
actnByte, propChp, offsetof(CHP, fBold), /* ipropBold */
actnByte, propChp, offsetof(CHP, fItalic), /* ipropItalic */
actnByte, propChp, offsetof(CHP, fUnderline), /* ipropUnderline */
actnWord, propPap, offsetof(PAP, xaLeft), /* ipropLeftInd */
actnWord, propPap, offsetof(PAP, xaRight), /* ipropRightInd */
actnWord, propPap, offsetof(PAP, xaFirst), /* ipropFirstInd */
actnWord, propSep, offsetof(SEP, cCols), /* ipropCols */
actnWord, propSep, offsetof(SEP, xaPgn), /* ipropPgnX */
actnWord, propSep, offsetof(SEP, yaPgn), /* ipropPgnY */
actnWord, propDop, offsetof(DOP, xaPage), /* ipropXaPage */
actnWord, propDop, offsetof(DOP, yaPage), /* ipropYaPage */
actnWord, propDop, offsetof(DOP, xaLeft), /* ipropXaLeft */
actnWord, propDop, offsetof(DOP, xaRight), /* ipropXaRight */
actnWord, propDop, offsetof(DOP, yaTop), /* ipropYaTop */
actnWord, propDop, offsetof(DOP, yaBottom), /* ipropYaBottom */
actnWord, propDop, offsetof(DOP, pgnStart), /* ipropPgnStart */
actnByte, propSep, offsetof(SEP, sbk), /* ipropSbk */
actnByte, propSep, offsetof(SEP, pgnFormat), /* ipropPgnFormat */
actnByte, propDop, offsetof(DOP, fFacingp), /* ipropFacingp */
actnByte, propDop, offsetof(DOP, fLandscape), /* ipropLandscape */
actnByte, propPap, offsetof(PAP, just), /* ipropJust */
actnSpec, propPap, 0, /* ipropPard */
actnSpec, propChp, 0, /* ipropPlain */
actnSpec, propSep, 0, /* ipropSectd */
};
/* Keyword descriptions */
SYM rgsymRtf[] = {
/* keyword dflt fPassDflt kwd idx */
"b", 1, fFalse, kwdProp, ipropBold,
"u", 1, fFalse, kwdProp, ipropUnderline,
"i", 1, fFalse, kwdProp, ipropItalic,
"ri", 0, fFalse, kwdProp, ipropRightInd,
"fi", 0, fFalse, kwdProp, ipropFirstInd,
"li", 0, fFalse, kwdProp, ipropLeftInd,
"cols", 1, fFalse, kwdProp, ipropCols,
"sbknone", sbkNon, fTrue, kwdProp, ipropSbk,
"sbkcol", sbkCol, fTrue, kwdProp, ipropSbk,
"sbkeven", sbkEvn, fTrue, kwdProp, ipropSbk,
"sbkodd", sbkOdd, fTrue, kwdProp, ipropSbk,
"sbkpage", sbkPg, fTrue, kwdProp, ipropSbk,
"pgnx", 0, fFalse, kwdProp, ipropPgnX,
"pgny", 0, fFalse, kwdProp, ipropPgnY,
"pgndec", pgDec, fTrue, kwdProp, ipropPgnFormat,
"pgnucrm", pgURom, fTrue, kwdProp, ipropPgnFormat,
"pgnlcrm", pgLRom, fTrue, kwdProp, ipropPgnFormat,
"pgnucltr", pgULtr, fTrue, kwdProp, ipropPgnFormat,
"pgnlcltr", pgLLtr, fTrue, kwdProp, ipropPgnFormat,
"qc", justC, fTrue, kwdProp, ipropJust,
"ql", justL, fTrue, kwdProp, ipropJust,
"qr", justR, fTrue, kwdProp, ipropJust,
"qj", justF, fTrue, kwdProp, ipropJust,
"paperw", 12240, fFalse, kwdProp, ipropXaPage,
"paperh", 15480, fFalse, kwdProp, ipropYaPage,
"margl", 1800, fFalse, kwdProp, ipropXaLeft,
"margr", 1800, fFalse, kwdProp, ipropXaRight,
"margt", 1440, fFalse, kwdProp, ipropYaTop,
"margb", 1440, fFalse, kwdProp, ipropYaBottom,
"pgnstart", 1, fTrue, kwdProp, ipropPgnStart,
"facingp", 1, fTrue, kwdProp, ipropFacingp,
"landscape",1, fTrue, kwdProp, ipropLandscape,
"pict", 0, fFalse, kwdProp, ipropImg,
"object", 0, fFalse, kwdProp, ipropImg,
"pntext", 0, fTrue, kwdProp, ipropPnText,
"par", 0, fTrue, kwdProp, ipropPar,
"pard", 0, fTrue, kwdProp, ipropPard,
"plain", 0, fTrue, kwdProp, ipropPlain,
"field", 0, fTrue, kwdProp, ipropField,
"bullet", 0, fTrue, kwdProp, ipropBullet,
"sect", 0, fTrue, kwdProp, ipropSectd,
"page", 0, fTrue, kwdProp, ipropPage,
"sb", 0, fTrue, kwdProp, ipropSB,
"chftn", 0, fTrue, kwdProp, ipropChftn,
"footnote", 0, fTrue, kwdProp, ipropFoot,
"fldrslt", 0, fTrue, kwdProp, ipropFldrslt,
"\0x0a", 0, fFalse, kwdChar, 0x0a,
"\0x0d", 0, fFalse, kwdChar, 0x0a,
"tab", 0, fFalse, kwdChar, 0x09,
"emdash", 0, fFalse, kwdChar, '-',
"endash", 0, fFalse, kwdChar, '-',
"ldblquote",0, fFalse, kwdChar, '"',
"rdblquote",0, fFalse, kwdChar, '"',
"lquote", 0, fFalse, kwdChar, '`',
"rquote", 0, fFalse, kwdChar, '\'',
"line", 0, fFalse, kwdChar, ' ',
"bin", 0, fFalse, kwdSpec, ipfnBin,
"*", 0, fFalse, kwdSpec, ipfnSkipDest,
"bkmkstart",0, fFalse, kwdBkmk, idestSkip,
"trowd", 0, fFalse, kwdTableau, idestSkip,
"intbl", 0, fFalse, kwdIntbl, idestSkip,
"cellx", 0, fFalse, kwdCellx, idestSkip,
"cell", 0, fFalse, kwdCell, idestSkip,
"row", 0, fFalse, kwdFinTableau, idestSkip,
"f", 0, fFalse, kwdFont, idestSkip,
"header", 0, fFalse, kwdHeader, idestSkip,
"s", 0, fFalse, kwdNiveau, idestSkip,
"'a", 0, fFalse, kwdAccent, idestSkip,
"'b", 0, fFalse, kwdAccent, idestSkip,
"'c", 0, fFalse, kwdAccent, idestSkip,
"'d", 0, fFalse, kwdAccent, idestSkip,
"'e", 0, fFalse, kwdAccent, idestSkip,
"'f", 0, fFalse, kwdAccent, idestSkip,
"'0", 0, fFalse, kwdAccent, idestSkip,
"'1", 0, fFalse, kwdAccent, idestSkip,
"'2", 0, fFalse, kwdAccent, idestSkip,
"'3", 0, fFalse, kwdAccent, idestSkip,
"'4", 0, fFalse, kwdAccent, idestSkip,
"'5", 0, fFalse, kwdAccent, idestSkip,
"'7", 0, fFalse, kwdAccent, idestSkip,
"'6", 0, fFalse, kwdAccent, idestSkip,
"'7", 0, fFalse, kwdAccent, idestSkip,
"'8", 0, fFalse, kwdAccent, idestSkip,
"'9", 0, fFalse, kwdAccent, idestSkip,
"author", 0, fFalse, kwdDest, idestSkip,
"buptim", 0, fFalse, kwdDest, idestSkip,
"colortbl", 0, fFalse, kwdDest, idestSkip,
"comment", 0, fFalse, kwdDest, idestSkip,
"creatim", 0, fFalse, kwdDest, idestSkip,
"doccomm", 0, fFalse, kwdDest, idestSkip,
"fonttbl", 0, fFalse, kwdDest, idestSkip,
"footer", 0, fFalse, kwdDest, idestSkip,
"footerf", 0, fFalse, kwdDest, idestSkip,
"footerl", 0, fFalse, kwdDest, idestSkip,
"footerr", 0, fFalse, kwdDest, idestSkip,
"fldinst", 0, fFalse, kwdDest, idestSkip,
"ftncn", 0, fFalse, kwdDest, idestSkip,
"ftnsep", 0, fFalse, kwdDest, idestSkip,
"ftnsepc", 0, fFalse, kwdDest, idestSkip,
"headerf", 0, fFalse, kwdDest, idestSkip,
"headerl", 0, fFalse, kwdDest, idestSkip,
"headerr", 0, fFalse, kwdDest, idestSkip,
"info", 0, fFalse, kwdDest, idestSkip,
"keywords", 0, fFalse, kwdDest, idestSkip,
"operator", 0, fFalse, kwdDest, idestSkip,
"printim", 0, fFalse, kwdDest, idestSkip,
"private1", 0, fFalse, kwdDest, idestSkip,
"revtim", 0, fFalse, kwdDest, idestSkip,
"rxe", 0, fFalse, kwdDest, idestSkip,
"stylesheet", 0, fFalse, kwdDest, idestSkip,
"subject", 0, fFalse, kwdDest, idestSkip,
"tc", 0, fFalse, kwdDest, idestSkip,
"title", 0, fFalse, kwdDest, idestSkip,
"txe", 0, fFalse, kwdDest, idestSkip,
"xe", 0, fFalse, kwdDest, idestSkip,
"{", 0, fFalse, kwdChar, '{',
"}", 0, fFalse, kwdChar, '}',
"\\", 0, fFalse, kwdChar, '\\',
"mac", 0, fFalse, kwdMac, idestSkip,
"ansi", 0, fFalse, kwdAnsi, idestSkip
};
int isymMax = sizeof(rgsymRtf) / sizeof(SYM);
/* ------------------------------------------------------------------------- */
/*
* %%Function: ecChangeDest
*
* Change to the destination specified by idest.
* There's usually more to do here than this...
*/
static int ecChangeDest(IDEST idest)
{
if (rds == rdsSkip) /* if we're skipping text, */
return ecOK; /* don't do anything */
switch (idest)
{
default:
rds = rdsSkip; /* when in doubt, skip it... */
break;
}
return ecOK;
}
/*
* %%Function: ecParseSpecialProperty
*
* Set a property that requires code to evaluate.
*/
static int ecParseSpecialProperty(IPROP iprop, int isym)
{
char tmp[MLEN];
register int ct;
switch (iprop)
{
case ipropChftn:
carniv = 0;
break;
/* Detection et prise en compte d'une image */
case ipropImg:
sprintf(tmp, "%s%d.gif", prefigure, ++nbFigure);
sprintf(tmp, "%s", GetImgSrcHTML(tmp));
TestLibPrintString(tmp, fpOut);
return ecChangeDest(rgsymRtf[isym].idx);
case ipropFldrslt:
nbResult = 0;
flagFldrslt = 1;
break;
/* DΘtection et prise en compte d'une note de bas de page */
case ipropFoot:
valCrochetF = crochet;
if(oldProp == ipropChftn && !carniv)
{
carniv = 0;
flagFootnote = 1;
nbFootnote += 1;
sprintf(tmp, "%d", nbFootnote);
if (flagFRAME)
sprintf(tmp, "%s%s%s",
TAG_B, GetAHNameTargetHTML(noteFile, NOTE_FRAME, tmp), TAGf_B);
else
sprintf(tmp, "%s%s%s", TAG_B, GetAHNameHTML(tmp), TAGf_B);
TestLibPrintString(tmp, fpOut);
Notes[carnot] = '\0';
if(strlen(Notes))
{
if(nbnote < MLEN / 2)
sprintf(lesNotes[nbnote++], "%s", Notes);
}
carnot = 0;
Notes[carnot] = '\0';
lesNotes[nbnote][0] = '\0';
}
break;
case ipropPar:
flagStop = 1;
if(!niveau)
{
if(flagTOC)
{
lesCar[nbcar] = '\0';
libPrintString(GetAHNameHTML(libRTrim(lesCar)), fpOut);
libPrintCharStd('\n', fpOut);
}
}
if(fontSize)
{
fontSize = 0;
libPrintString(TAGf_FONT, fpOut);
}
if (strlen(Url) > 4)
{
libPrintString(GetHrefHTML2(Url, Url),fpOut);
flagStop = 0;
nbUrl = 0;
Url[nbUrl] = '\0';
}
if (!flagTableau)
{
if(flagBR_P == 1)
{
if(tagDD)
sprintf(tmp, "%s\n", TAG_BR);
else
sprintf(tmp, "%s\n", TAG_P);
}
else if(flagBR_P == 0)
sprintf(tmp, "%s\n", TAG_BR);
}
else if (flagTableau)
sprintf(tmp, "%s\n", TAG_BR);
TestLibPrintString(tmp, fpOut);
nbcar = 0;
flagDD = 0;
break;
case ipropPnText:
nbcar = 0;
flagPnText = 1;
break;
case ipropPard:
memset(&pap, 0, sizeof(pap));
ecDetectPard();
break;
case ipropPlain:
memset(&chp, 0, sizeof(chp));
break;
case ipropSB:
if (!flagFootnote)
{
TestLibPrintString(TAG_P, fpOut);
libPrintCharStd('\n', fpOut);
}
break;
/* Detection saut de page ou changement de section */
case ipropPage:
case ipropSectd:
memset(&sep, 0, sizeof(sep));
/* Affichage de fin de style eventuel */
ecPrintItalicF (fpOut);
ecPrintBoldF (fpOut);
if(tagUL)
{
tagUL = 0;
libPrintString(TAGf_UL, fpOut);
libPrintCharStd('\n', fpOut);
while(flagTOC)
{
flagTOC -= 1;
libPrintCharStd('\n', fpOut);
libPrintString(TAGf_UL, fpOut);
libPrintCharStd('\n', fpOut);
}
}
flagTOC = 0;
if(tagCenter)
{
tagCenter = 0;
libPrintCharStd('\n', fpOut);
libPrintString(TAGf_CENTER, fpOut);
libPrintCharStd('\n', fpOut);
}
if(niveau)
{
leNiveau [carniv] = '\0';
if(strlen(libRTrim(leNiveau)))
{
libPrintString(GetNiveauHTML(niveau + plusNiveau), fpOut);
libPrintString(GetANameHTML(leNiveau), fpOut);
libPrintString(GetNiveauHTMLf(niveau + plusNiveau), fpOut);
if (flagFRAME)
{
if (niveau == oldNiveau)
{
libPrintCharStd('\n', fpTable);
libPrintString(TAG_LI, fpTable);
libPrintString(GetAHNameTargetHTML(pageFile, PAGE_FRAME, leNiveau), fpTable);
}
else
{
if (niveau < oldNiveau)
{
for (ct = niveau; ct <= oldNiveau; ct++)
libPrintString(TAGf_UL, fpTable);
}
else if (niveau > oldNiveau && oldNiveau > 0)
libPrintString(TAG_UL, fpTable);
libPrintCharStd('\n', fpTable);
libPrintString(TAG_LI, fpTable);
libPrintString(GetAHNameTargetHTML(pageFile, PAGE_FRAME, leNiveau), fpTable);
}
libPrintCharStd('\n', fpTable);
}
oldNiveau = niveau;
}
}
if(flagFootnote == -1)
ecFootnote();
if(flagBR_P == 1)
{
if(tagDD)
{
libPrintString(TAG_BR, fpOut);
}
else
libPrintString(TAG_P, fpOut);
}
else
{
libPrintString(TAG_BR, fpOut);
}
libPrintString(TAG_HR4, fpOut);
libPrintString(TAG_BR, fpOut);
libPrintCharStd('\n', fpOut);
tagLI = 0;
nbcar = 0;
niveau = 0;
flagDD = 0;
flagTOC = 0;
flagFootnote = 0;
//detectField = 0;
break;
case ipropField:
//detectField = 1;
break;
case ipropFldinst:
break;
case ipropBullet:
sprintf(tmp, "\n%s", TAG_LI);
TestLibPrintString(tmp, fpOut);
break;
case ipropItalic:
if(!flagTOC && !niveau)
ecPrintItalic(fpOut);
break;
case ipropBold:
if(!flagTOC && !niveau)
ecPrintBold(fpOut);
break;
case ipropUnderline:
break;
default:
return ecBadTable;
}
oldProp = iprop;
return ecOK;
}
/*
* %%Function: ecApplyPropChange
*
* Set the property identified by _iprop_ to the value _val_.
*/
static int ecApplyPropChange(IPROP iprop, int val, int isym)
{
char * pb = (char *)0;
if (rds == rdsSkip) /* If we're skipping text, */
return ecOK; /* don't do anything. */
switch (rgprop[iprop].prop)
{
case propDop:
pb = (char *)&dop;
break;
case propSep:
pb = (char *)&sep;
break;
case propPap:
pb = (char *)&pap;
break;
case propChp:
pb = (char *)&chp;
break;
default:
if (rgprop[iprop].actn != actnSpec)
return ecBadTable;
break;
}
switch (rgprop[iprop].actn)
{
case actnByte:
pb[rgprop[iprop].offset] = (unsigned char) val;
if (rgprop[iprop].prop == propChp)
return ecParseSpecialProperty(iprop, isym);
if(val == justC)
ecPrintCenter(fpOut);
break;
case actnWord:
if(rgprop[iprop].offset == offsetof(PAP, xaLeft))
{
tagDD = 1;
flagDD = 1;
libPrintString(TAG_DD, fpOut);
}
else
{
(*(int *) (pb+rgprop[iprop].offset)) = val;
}
break;
case actnSpec:
return ecParseSpecialProperty(iprop, isym);
default:
return ecBadTable;
}
return ecOK;
}
/*
* %%Function: ecParseSpecialKeyword
*
* Evaluate an RTF control that needs special processing.
*/
static int ecParseSpecialKeyword(IPFN ipfn)
{
/* if we're skipping, and it's not */
if (rds == rdsSkip && ipfn != ipfnBin)
return ecOK; /* the \bin keyword, ignore it. */
switch (ipfn)
{
case ipfnBin:
ris = risBin;
cbBin = lParam;
break;
case ipfnSkipDest:
fSkipDestIfUnk = fTrue;
break;
case ipfnHex:
ris = risHex;
break;
default:
return ecBadTable;
}
return ecOK;
}
/*
* %%Function: ecTranslateKeyword.
*
* Step 3.
* Search rgsymRtf for szKeyword and evaluate it appropriately.
*
* Inputs:
* szKeyword: The RTF control to evaluate.
* param: The parameter of the RTF control.
* fParam: fTrue if the control had a parameter; (i.e., if param is valid)
* fFalse if it did not.
*/
int ecTranslateKeyword(char * szKeyword, int param, bool fParam)
{
int isym = 0, ct;
char * tag = (char *)0;
/* search for szKeyword in rgsymRtf */
for (isym = 0; isym < isymMax; isym++)
{
if (strcmp(szKeyword, rgsymRtf[isym].szKeyword) == 0)
break;
}
if (isym == isymMax) /* control word not found */
{
if (fSkipDestIfUnk) /* if this is a new destination */
rds = rdsSkip; /* skip the destination */
/* else just discard it */
fSkipDestIfUnk = fFalse;
return ecOK;
}
/* found it! use kwd and idx to determine what to do with it. */
fSkipDestIfUnk = fFalse;
switch (rgsymRtf[isym].kwd)
{
case kwdProp:
if (rgsymRtf[isym].fPassDflt || !fParam)
param = rgsymRtf[isym].dflt;
return ecApplyPropChange(rgsymRtf[isym].idx, param, isym);
case kwdChar:
return ecParseChar(rgsymRtf[isym].idx);
case kwdDest:
return ecChangeDest(rgsymRtf[isym].idx);
case kwdSpec:
return ecParseSpecialKeyword(rgsymRtf[isym].idx);
/* Bookmark */
case kwdBkmk:
flagBKMK = 1;
nbBk = 0;
lesBkmk[nbBk] = '\0';
break;
case kwdIntbl:
/* Le format tableau RTF doit correpondre de maniere
* "generale" a :
* \trowd ... \cellx... \pard ... \intbl ... \cell ... \row
*
* \trowd : indique un debut de tableau
* \cell : indique une fin de cellule
* \row : indique une fin de tableau
*
* Si on detecte de \intbl sans etre dans un tableau cela
* signifie que le paragraphe en cours appartient au tableau
* precedent.
* Il est donc necessaire de revenir dans le fichier de sortie
* avant la fermture du tableau HTML (ouf!!...).
*/
if(flagTableau == 0)
{
fflush(fpOut);
if(tagCenter)
{
if(!(fseek(fpOut, ftell(fpOut) - (strlen(TAGf_TABLE) + strlen(TAG_CENTER)+10), SEEK_SET)))
flagTableau = 1;
tagCenter = 0;
}
else
{
if(!(fseek(fpOut, ftell(fpOut) - (strlen(TAGf_TABLE) +7), SEEK_SET)))
flagTableau = 1;
}
tagUL = 0;
if(!tagTR)
{
tagTR = 1;
libPrintString(TAG_TR, fpOut);
libPrintCharStd('\n', fpOut);
}
}
break;
/* Mode Tableau */
case kwdTableau:
if(flagTableau == 0)
{
if(tagCenter)
{
tagCenter = 0;
libPrintCharStd('\n', fpOut);
libPrintString(TAGf_CENTER, fpOut);
libPrintCharStd('\n', fpOut);
}
libPrintString(GetTableHTML(), fpOut);
}
if(!tagTR)
{
tagTR = 1;
libPrintString(TAG_TR, fpOut);
libPrintCharStd('\n', fpOut);
}
flagTableau = 1;
break;
case kwdCellx:
nbcell +=1;
break;
case kwdCell:
switch(flagTableau)
{
case 0:
flagTableau = 1;
libPrintString(GetTableHTML(), fpOut);
if(!tagTR)
{
tagTR = 1;
libPrintString(TAG_TR, fpOut);
libPrintCharStd('\n', fpOut);
}
break;
case -1:
case 1:
break;
}
if(!strlen(cellule))
sprintf(cellule, "-");
if(nbcell == 1)
{
if(oldnbcell > nbcell)
{
CelluleColHTML(cellule, fpOut, oldnbcell + 1);
}
else
{
CelluleColHTML(cellule, fpOut, (nbcell ? nbcell : 1) + 1);
}
}
else
{
CelluleHTML(cellule, fpOut);
}
if(tagCenter)
{
tagCenter = 0;
libPrintString(TAGf_CENTER, fpOut);
libPrintCharStd('\n', fpOut);
}
/* Affichage de fin de style eventuel */
ecPrintItalicF (fpOut);
ecPrintBoldF (fpOut);
carcell = 0;
cellule[carcell] = '\0';
break;
/* Fin de tableau */
case kwdFinTableau:
if(tagTR)
{
libPrintString(TAGf_TR, fpOut);
}
if(tagCenter)
{
tagCenter = 0;
libPrintString(TAGf_CENTER, fpOut);
}
tagTR = 0;
oldnbcell = nbcell;
nbcell = 0;
flagTableau = -1;
break;
case kwdHeader:
flagHeader = 1;
valCrochetH = crochet;
break;
case kwdFont:
break;
/* Detection des niveaux : */
case kwdNiveau:
/* Equivalence de designation des niveau US->Fr. */
switch(param)
{
case 41:
param = 1;
case 42:
param = 2;
case 43:
param = 3;
case 44:
param = 4;
case 45:
param = 5;
case 46:
param = 6;
case 47:
param = 6;
case 48:
param = 8;
case 49:
param = 9;
}
if(niveau)
{
leNiveau [carniv] = '\0';
if(strlen(libRTrim(leNiveau)))
{
libPrintString(GetNiveauHTML(niveau + plusNiveau), fpOut);
libPrintString(GetANameHTML(leNiveau), fpOut);
libPrintString(GetNiveauHTMLf(niveau + plusNiveau), fpOut);
if (flagFRAME)
{
if (niveau == oldNiveau)
{
libPrintCharStd('\n', fpTable);
libPrintString(TAG_LI, fpTable);
libPrintString(GetAHNameTargetHTML(pageFile, PAGE_FRAME, leNiveau), fpTable);
}
else
{
if (niveau < oldNiveau)
{
for (ct = niveau; ct <= oldNiveau; ct++)
libPrintString(TAGf_UL, fpTable);
}
else if (niveau > oldNiveau && oldNiveau > 0)
libPrintString(TAG_UL, fpTable);
libPrintCharStd('\n', fpTable);
libPrintString(TAG_LI, fpTable);
libPrintString(GetAHNameTargetHTML(pageFile, PAGE_FRAME, leNiveau), fpTable);
}
libPrintCharStd('\n', fpTable);
}
oldNiveau = niveau;
}
}
carniv = 0;
niveau = 0;
leNiveau [carniv] = '\0';
tag = GetNiveauHTML(param + plusNiveau);
if(tagUL && tag)
{
tagUL = 0;
libPrintCharStd('\n', fpOut);
libPrintString(TAGf_UL, fpOut);
libPrintCharStd('\n', fpOut);
}
if(tag)
{
niveau = param ? param : 1;
lesCar[nbcar] = '\0';
if(flagPnText == 1 && strlen(lesCar))
{
sprintf(leNiveau, "%s", lesCar);
carniv = nbcar;
}
}
flagPnText = 0;
nbcar = 0;
break;
/* Detection des accents : */
case kwdAccent:
if(flagGO)
{
return HexaToHtmlOrTxt(szKeyword, param, fParam);
}
break;
case kwdMac:
return ecMacFile;
case kwdAnsi:
break;
default:
return ecBadTable;
}
return ecOK;
}
/*
* %%Function: ecEndGroupAction
*
* The destination specified by rds is coming to a close.
* If there's any cleanup that needs to be done, do it now.
*/
int ecEndGroupAction(RDS rds)
{
return ecOK;
}
/*
* %%Function: ecDetectPard
*
*/
void ecDetectPard(void)
{
int ct;
if (oldProp != ipropFoot)
{
/* Affichage de fin de style eventuel */
ecPrintItalicF (fpOut);
ecPrintBoldF (fpOut);
}
if(tagLI && !valCrochetF)
{
tagLI = 0;
libPrintString(TAGf_BQUOTE, fpOut);
libPrintCharStd('\n', fpOut);
}
if(flagTableau == -1)
{
tagUL = 1;
if(tagTR)
{
libPrintString(TAGf_TR, fpOut);
libPrintCharStd('\n', fpOut);
}
libPrintString(TAGf_TABLE, fpOut);
libPrintCharStd('\n', fpOut);
flagTableau = 0;
tagTR = 0;
}
if(niveau && !flagTOC)
{
leNiveau [carniv] = '\0';
if(strlen(libRTrim(leNiveau)))
{
libPrintString(GetNiveauHTML(niveau + plusNiveau), fpOut);
libPrintCharStd('\n', fpOut);
libPrintString(GetANameHTML(leNiveau), fpOut);
libPrintString(GetNiveauHTMLf(niveau + plusNiveau), fpOut);
libPrintCharStd('\n', fpOut);
if (flagFRAME)
{
if (niveau == oldNiveau)
{
libPrintCharStd('\n', fpTable);
libPrintString(TAG_LI, fpTable);
libPrintString(GetAHNameTargetHTML(pageFile, PAGE_FRAME, leNiveau), fpTable);
}
else
{
if (niveau < oldNiveau)
{
for (ct = niveau; ct <= oldNiveau; ct++)
libPrintString(TAGf_UL, fpTable);
}
else if (niveau > oldNiveau && oldNiveau > 0)
libPrintString(TAG_UL, fpTable);
libPrintCharStd('\n', fpTable);
libPrintString(TAG_LI, fpTable);
libPrintString(GetAHNameTargetHTML(pageFile, PAGE_FRAME, leNiveau), fpTable);
}
libPrintCharStd('\n', fpTable);
}
oldNiveau = niveau;
}
tagUL = 1;
niveau = 0;
carniv = 0;
leNiveau [carniv] = '\0';
libPrintCharStd('\n', fpOut);
libPrintString(TAG_UL, fpOut);
libPrintCharStd('\n', fpOut);
}
if(tagCenter)
{
if(oldProp != ipropFoot)
{
libPrintCharStd('\n', fpOut);
tagCenter = 0;
if(!flagTableau)
{
libPrintString(TAGf_CENTER, fpOut);
libPrintCharStd('\n', fpOut);
}
}
}
if(fontSize)
{
fontSize = 0;
libPrintString(TAGf_FONT, fpOut);
}
if(!flagPnText)
nbcar = 0;
oldnbcell = 0;
flagGO = 1;
//detectField = 0;
oldProp = ipropPard;
}
/*
* %%Function: ecFootnote.
*
* Affiche la liste des notes de bas de page decouvert.
*/
void ecFootnote(void)
{
char tmp[5];
int i = 0;
Notes[carnot] = '\0';
if(strlen(Notes))
{
if(nbnote < MLEN / 2)
{
sprintf(lesNotes[nbnote++], "%s", Notes);
lesNotes[nbnote][0] = '\0';
}
}
for (i = 0; i < nbnote; i++)
{
if(!lesNotes[i])
continue;
flagNote = 1;
if(flagBR_P)
{
if (flagFRAME)
libPrintString(TAG_P, fpNote);
else
libPrintString(TAG_P, fpOut);
}
else
{
if (flagFRAME)
libPrintString(TAG_BR, fpNote);
else
libPrintString(TAG_BR, fpOut);
}
if (flagFRAME)
libPrintCharStd('\n', fpNote);
else
libPrintCharStd('\n', fpOut);
sprintf(tmp, "%d", (nbFootnote - (nbnote-1)) + i);
if (flagFRAME)
{
libPrintString("<B><EM>", fpNote);
libPrintString(GetANameHTML(tmp), fpNote);
libPrintString("</EM></B>", fpNote);
}
else
{
libPrintString("<B><EM>", fpOut);
libPrintString(GetANameHTML(tmp), fpOut);
libPrintString("</EM></B>", fpOut);
}
if(lesNotes[i])
{
if (flagFRAME)
{
libPrintString(TAG_CITE, fpNote);
libPrintString(lesNotes[i], fpNote);
libPrintString(TAGf_CITE, fpNote);
libPrintCharStd('\n', fpNote);
}
else
{
libPrintString(TAG_CITE, fpOut);
libPrintString(lesNotes[i], fpOut);
libPrintString(TAGf_CITE, fpOut);
libPrintCharStd('\n', fpOut);
}
}
if(flagBR_P)
{
if (flagFRAME)
libPrintString(TAG_P, fpNote);
else
libPrintString(TAG_P, fpOut);
}
else
{
if (flagFRAME)
libPrintString(TAG_BR, fpNote);
else
libPrintString(TAG_BR, fpOut);
}
lesNotes[i][0] = '\0';
}
carnot = 0;
nbnote = 0;
lesNotes[nbnote][0] = '\0';
Notes[carnot] = '\0';
}
/*
* %%Function: ecPrintItalic.
*
* Affiche un style italique.
*/
void ecPrintItalic(FILE * sortie)
{
if (styleItalic || !crochet)
return ;
valCrochetI = crochet;
styleItalic = 1;
TestLibPrintString(TAG_I, sortie);
}
/*
* %%Function: ecPrintItalicF
*
* Affiche une fin de style italique.
*/
void ecPrintItalicF(FILE * sortie)
{
if (!styleItalic)
return ;
if (valCrochetI != crochet)
return ;
valCrochetI = 0;
styleItalic = 0;
TestLibPrintString(TAGf_I, sortie);
}
/*
* %%Function: ecPrintBold.
*
* Affiche un style gras.
*/
void ecPrintBold(FILE * sortie)
{
if (styleBold || !crochet)
return ;
valCrochetB = crochet;
styleBold = 1;
TestLibPrintString(TAG_B, sortie);
}
/*
* %%Function: ecPrintBoldF.
*
* Affiche une fin de style gras.
*/
void ecPrintBoldF(FILE * sortie)
{
if (!styleBold)
return ;
if (valCrochetB != crochet)
return ;
valCrochetB = 0;
styleBold = 0;
TestLibPrintString(TAGf_B, sortie);
}
/*
* %%Function: ecPrintCenter.
*
* Affiche une centre HTML.
*/
void ecPrintCenter(FILE * sortie)
{
tagCenter = 1;
TestLibPrintString(TAG_CENTER, sortie);
TestLibPrintString("\n", fpOut);
}